home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’90 / MiniFinder / mini.a < prev    next >
Text File  |  1990-06-13  |  6KB  |  273 lines

  1. * MiniFinder -- Small Icons on the Desktop.
  2. *    by Dean Yu
  3.  
  4.             INCLUDE 'ToolEqu.a'
  5.             INCLUDE 'SysEqu.a'
  6.             INCLUDE 'Traps.a'
  7.             INCLUDE 'QuickEqu.a'
  8.  
  9. main        PROC    EXPORT
  10.             IMPORT    copyPatch
  11.             IMPORT    rectPatch
  12.             IMPORT    rgnPatch
  13.             IMPORT    cPort
  14.             
  15.             move.l    d7,-(sp)
  16.             
  17.             lea        main,a0
  18.             _RecoverHandle ,SYS
  19.             move.l    a0,-(sp)
  20.             _DetachResource                ; Detach it so it sticks around
  21.  
  22.             move.w    #$ec,d0                ; Trap number for _CopyBits
  23.             _GetTrapAddress ,NEWTOOL
  24.             lea        copyPatch,a1
  25.             move.l    a0,2(a1)            ; Save old _CopyBits routine
  26.             move.l    a1,a0
  27.             move.w    #$ec,d0
  28.             _SetTrapAddress ,NEWTOOL
  29.             
  30.             move.w    #$a4,d0                ; Trap number for _InverRect
  31.             _GetTrapAddress ,NEWTOOL
  32.             lea        rectPatch,a1
  33.             move.l    a0,2(a1)            ; Save old _InverRect routine
  34.             move.l    a1,a0
  35.             move.w    #$a4,d0
  36.             _SetTrapAddress ,NEWTOOL
  37.             
  38.             move.w    #$db,d0                ; Trap number for _CloseRgn
  39.             _GetTrapAddress ,NEWTOOL
  40.             lea        rgnPatch,a1
  41.             move.l    a0,2(a1)            ; Save old _CloseRgn routine
  42.             move.l    a1,a0
  43.             move.w    #$db,d0
  44.             _SetTrapAddress ,NEWTOOL
  45.             
  46.             move.w    #$9f,d0
  47.             _GetTrapAddress ,NEWTOOL    ; Unimplemented trap number
  48.             move.l    a0,d7
  49.             move.w    #$aa00,d0            ; Trap number for _OpenCPort
  50.             _GetTrapAddress ,NEWTOOL
  51.             cmp.l    a0,d7
  52.             beq.s    noCQD                ; No Color QuickDraw
  53.             lea        cPort,a1
  54.             move.l    a0,2(a1)            ; Save old _OpenCPort routine
  55.             move.l    a1,a0
  56.             move.w    #$aa00,d0
  57.             _SetTrapAddress ,NEWTOOL
  58.             bra.s    ExitINIT
  59.             
  60. noCQD        move.w    #$6f,d0                ; Trap number for _OpenPort
  61.             _GetTrapAddress ,NEWTOOL
  62.             lea        cPort,a1
  63.             move.l    a0,2(a1)            ; Save old _OpenPort routine
  64.             move.l    a1,a0
  65.             move.w    #$6f,d0
  66.             _SetTrapAddress ,NEWTOOL
  67.  
  68. ExitINIT    move.l    (sp)+,d7
  69.             rts
  70.             ENDPROC
  71.  
  72. copyPatch    PROC    EXPORT
  73.             IMPORT    rgnPatch
  74.             IMPORT    rectPatch
  75. copyVars    RECORD    {A6Link},DECR
  76. paramBegin    equ        *
  77. srcBits        ds.l    1                    ; Pointer to source bit map
  78. dstBits        ds.l    1                    ; Pointer to destination bit map
  79. srcRect        ds.l    1                    ; Pointer to source rectangle
  80. dstRect        ds.l    1                    ; Pointer to destination rectangle
  81. mode        ds.w    1                    ; Transfer mode
  82. maskRgn        ds.l    1                    ; Region handle
  83. paramSize    equ        paramBegin - *
  84. retAddr        ds.l    1                    ; Return address
  85. A6Link        ds.l    1                    ; Stack frame
  86. localSize    equ        *
  87.             ENDR
  88.             
  89.             WITH    copyVars
  90.             bra.s    startCopy
  91. oldCopy        ds.l    1
  92. theDesktop    ds.l    1
  93. startCopy    lea        FinderName,a0        ; Make sure we’re only active in the Finder
  94.             lea        CurApName,a1
  95.             
  96.             cmpi.b    #$ff,(a0)            ; Special case for startup time
  97.             beq.s    toOldCopy
  98.             
  99.             cmp.l    (a0)+,(a1)+
  100.             bne.s    toOldCopy
  101.             cmp.w    (a0)+,(a1)+
  102.             bne.s    toOldCopy
  103.             
  104.             move.l    theDesktop,a0        ; Don’t do anything unless we’re drawing in the
  105.             move.l    (a5),a1                ; desktop port
  106.             move.l    (a1),a1
  107.             cmp.l    a0,a1
  108.             bne.s    toOldCopy
  109.             
  110.             link    a6,#localSize
  111.             move.l    srcRect(a6),a0
  112.             move.l    (a0),d0
  113.             move.l    botRight(a0),d1
  114.             sub.l    d0,d1
  115.             cmpi.l    #$00200020,d1        ; Make sure source rectangle is 32 x 32
  116.             bne.s    exitCopy
  117.             
  118.             move.l    dstRect(a6),a0        ; Get pointer to desination rectangle
  119.             move.l    (a0),d0                ; Get topLeft
  120.             move.l    botRight(a0),d1        ; Get botRight
  121.             sub.l    d0,d1                ; Get size of destination rectangle
  122.             cmpi.l    #$00200020,d1        ; Is it 32 x 32?
  123.             bne.s    exitCopy            ; If not, don’t do anything
  124.             
  125.             addi.l    #$00100010,d0        ; Make 16 x 16 destRect
  126.             move.l    d0,botRight(a0)
  127.             
  128.             move.l    a0,-(sp)            ; Center it in old destRect
  129.             move.l    #$000f0008,-(sp)
  130.             _OffsetRect
  131.             
  132.             cmpi.w    #srcBic,mode(a6)
  133.             bne.s    exitCopy
  134.             
  135.             lea        rgnPatch,a0
  136.             move.w    #$ff,6(a0)
  137.             
  138.             lea        rectPatch,a0
  139.             move.w    #$ff,6(a0)
  140.             
  141. exitCopy    unlk    a6
  142. toOldCopy    move.l    oldCopy,a0
  143.             jmp        (a0)
  144.             ENDPROC
  145.             
  146. rectPatch    PROC    EXPORT
  147.             IMPORT    rgnPatch
  148.             
  149.             bra.s    startPatch
  150. oldRect        ds.l    1
  151. active        dc.w    0
  152.  
  153. startPatch    move.w    active,d0
  154.             beq.s    toOldRect
  155.             
  156.             lea        FinderName,a0        ; Make sure we’re only active in the Finder
  157.             lea        CurApName,a1
  158.             
  159.             cmp.l    (a0)+,(a1)+
  160.             bne.s    toOldRect
  161.             cmp.w    (a0)+,(a1)+
  162.             bne.s    toOldRect
  163.  
  164.             lea        rgnPatch,a1
  165.             move.l    4(sp),a0
  166.             move.l    (a0)+,8(a1)
  167.             move.l    (a0)+,12(a1)
  168.             
  169.             lea        active,a0
  170.             clr.w    (a0)
  171.             
  172. toOldRect    move.l    oldRect,a0
  173.             jmp        (a0)
  174.             ENDPROC
  175.             
  176. rgnPatch    PROC    EXPORT
  177.             bra.s    startPatch
  178. oldRgn        ds.l    1
  179. active        dc.w    0
  180. theRect        ds.l    1
  181. theRect2        ds.l    1
  182. whichWind    ds.l    1
  183.  
  184. startPatch    move.w    active,d0
  185.             beq.s    toOldCloseRgn
  186.             
  187.             lea        FinderName,a0        ; Make sure we’re only active in the Finder
  188.             lea        CurApName,a1
  189.             
  190.             cmp.l    (a0)+,(a1)+
  191.             bne.s    toOldCloseRgn
  192.             cmp.w    (a0)+,(a1)+
  193.             bne.s    toOldCloseRgn
  194.             
  195.             sub.w    #2,sp
  196.             
  197.             pea        whichWind
  198.             move.l    (sp),-(sp)
  199.             _GetMouse
  200.             _LocalToGlobal
  201.             move.l    whichWind,-(sp)
  202.             pea        whichWind
  203.             _FindWindow
  204.             tst.w    (sp)+
  205.             bne.s    toOldCloseRgn
  206.             
  207.             move.l    4(sp),-(sp)
  208.             move.l    oldRgn,a0
  209.             jsr        (a0)
  210.             
  211.             move.l    4(sp),-(sp)
  212.             move.l    #$00060006,-(sp)
  213.             _InsetRgn
  214.             
  215.             move.l    #10,d0
  216.             _NewHandle
  217.             lea        whichWind,a1
  218.             move.l    a0,(a1)
  219.             
  220.             move.l    (a0),a0
  221.             move.w    #10,(a0)+
  222.             move.l    theRect,(a0)+
  223.             move.l    theRect2,(a0)+
  224.             
  225.             move.l    4(sp),a0
  226.             move.l    a0,-(sp)
  227.             move.l    whichWind,-(sp)
  228.             move.l    a0,-(sp)
  229.             _UnionRgn
  230.             
  231.             move.l    whichWind,a0
  232.             _DisposHandle
  233.             
  234.             lea        active,a0
  235.             clr.w    (a0)
  236.             
  237.             move.l    (sp)+,a0
  238.             add.w    #4,sp
  239.             jmp        (a0)
  240.             
  241. toOldCloseRgn    move.l    oldrgn,a0
  242.             jmp        (a0)
  243.             ENDPROC
  244.             
  245. cPort        PROC    EXPORT
  246.             IMPORT    copyPatch
  247.             bra.s    startCPort
  248. oldCPort    ds.l    1
  249. active        dc.w    1
  250. startCPort    move.w    active,d0
  251.             beq.s    toOldCPort
  252.             
  253.             lea        FinderName,a0        ; Make sure we’re only active in the Finder
  254.             lea        CurApName,a1
  255.             
  256.             cmpi.b    #$ff,(a0)            ; Special case for startup time
  257.             beq.s    toOldCPort
  258.             
  259.             cmp.l    (a0)+,(a1)+
  260.             bne.s    toOldCPort
  261.             cmp.w    (a0)+,(a1)+
  262.             bne.s    toOldCPort
  263.             
  264.             lea        active,a0
  265.             clr.w    (a0)
  266.             
  267.             lea        copyPatch,a0
  268.             move.l    4(sp),6(a0)            ; Save desktop port
  269.             
  270. toOldCPort    move.l    oldCPort,a0
  271.             jmp        (a0)
  272.             ENDPROC
  273.             END